<?php
header('Content-type:text/html;charset=utf-8');
session_start();
include_once 'dbconfig.php';
include_once 'common.php';

if ($_POST) {
    if (isset($_POST['postType']) && $_POST['postType'] == 'removeItems') {
        $idStr = implode($_POST['ids'], ',');
        if (isset($_SESSION['loginUserName'])) {
            $name = $_SESSION['loginUserName'];
        } else {
            $msg = ['msg' => '请先登录！', 'status' => 0];
            responseEvent($msg);
        }
        $str = 'update shop_cart set status = 0 where username = "' . $name . '" and id in(' . $idStr . ')';
        if ($link->query($str) === true) {
            $msg = ['msg' => '移除购物车成功！', 'status' => 1];
        } else {
            $msg = ['msg' => '移除购物车失败！', 'status' => 0];
        }
        responseEvent($msg);
    }
}